package com.springboot.template.service.impl;

import com.springboot.template.service.ThreadPoolService;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class ThreadPoolServiceImpl implements ThreadPoolService {

    @Override
    @Async("taskExecutor")
    public void asyncMethod() {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("This is an async method using thread pool." + Thread.currentThread().getName());
    }
}
